<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <script>
        // es6用class定义面向对象
        // class是面向对象的语法糖
        // 属性定义在constructor里
        // 方法定义在class里

        class People {
            constructor(n, a) {
                this.name = n;
                this.age = a;
            }
            say() {
                alert(this.name + "人都会说话");
            }
        }

        let libai = new People("李白", 30);
        libai.say();

        class Man extends People {
            constructor(n, a) {
                super(n, a);
            }
        }
        let laowang = new Man("老王", 30);
        alert(laowang.name);
        // es6的继承 super+extends
    </script>
</body>

</html>

</html>